package com.xiyan.blog.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.Version;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author: ruiyanglee
 * @date: 2020-09-07 15:34
 * @description: 基础实体类
 */
@Data
public class BaseEntity implements Serializable {

    protected String id;

    // 创建时自动填充时间
    @TableField(fill = FieldFill.INSERT)
    @ApiModelProperty(value = "创建时间")
    private LocalDateTime createTime;


    // 更新实体或者某个字段时自动填充更新时间
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @ApiModelProperty(value = "修改时间")
    private LocalDateTime updateTime;

    // 逻辑删除：在properties中
    @TableLogic
    @ApiModelProperty(value = "是否有效, 1 删除 0 未删除")
    private Integer deleted;

    //乐观锁处理并发操作
    @Version
    @ApiModelProperty(value = "版本号")
    private Integer version;

}
